﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="list.aspx.vb" Inherits="AssignmentProject.WebForm1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $("#ShowTopBTN").toggle(
       function () {
           $("#mostLikedPane").slideDown(300);

       },
       function () {
           $("#mostLikedPane").fadeOut(600);

       }
       );
    });
    </script>
    <style type="text/css">
    #container
    {
        position:absolute;
        left:44%;
    }
    #mostLikedPane { display:none;}
       
    .mostLikedContent {width: 400px;margin:0 auto;}
    </style>
    <style type="text/css">
        .style1
        {
            width: 844px;
            height: 180px;
        }
    </style>
     
  
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
    <p>
    </p>
    <p>
        <img alt="Welcome to Gobblz" class="style1" src="Images/WebIntros.jpg" /></p>
    <div>
        <asp:Button ID="ShowTopBTN" runat="server" Text="Most Liked Recipes Toggle" clientIDmode="Static"/>
    <div class="mostLikedContent" id="mostLikedPane" clientidmode="Static">
   
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSourceLikes" 
            PageSize="3" GridLines="None">
            <Columns>
                <asp:BoundField DataField="RecipeName" HeaderText="Recipe Name" 
                    SortExpression="RecipeName" />
                <asp:BoundField DataField="UserLikes" HeaderText="User Likes" 
                    SortExpression="UserLikes" />
                <asp:HyperLinkField DataNavigateUrlFields="ID" 
                    DataNavigateUrlFormatString="details.aspx?ID={0}" Text="More Details!" />
            </Columns>
        </asp:GridView>

        <asp:SqlDataSource ID="SqlDataSourceLikes" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
            SelectCommand="SELECT [UserLikes], [ID], [RecipeName] FROM [CompLikesCount] ORDER BY [UserLikes] DESC">
        </asp:SqlDataSource>

    </div>
    
    </div>
    <div>
      <p>
          Most viewed Recipe</p>
        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
            DataSourceID="mostviewedsrc" GridLines="None" HorizontalAlign="Center">
            <Columns>
                <asp:BoundField DataField="RecipeName" HeaderText="Recipe" 
                    SortExpression="RecipeName" />
                <asp:BoundField DataField="MaxOftotalviews" HeaderText="Views" 
                    SortExpression="MaxOftotalviews" />
                <asp:HyperLinkField DataNavigateUrlFields="Recipe_FKID" 
                    DataNavigateUrlFormatString="details.aspx?ID={0}" Text="More Details" />
            </Columns>
        </asp:GridView>
          <asp:SqlDataSource ID="mostviewedsrc" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
            
            SelectCommand="SELECT TOP 1 MaxOftotalviews, Recipe_FKID, RecipeName FROM totalviewquery ORDER BY MaxOftotalviews DESC">
        </asp:SqlDataSource>
          </div>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
        <div id="container2Div" style="text-align:center;">
        <div id="centeredDiv2" style="width:50%; margin:auto; text-align:left;">
    <p>
        <asp:SqlDataSource ID="TagsDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
            SelectCommand="SELECT [Tag] FROM [Tags]"></asp:SqlDataSource>


        <asp:DataList ID="DataList1" runat="server" DataSourceID="TagsDataSource" 
            RepeatDirection="Horizontal">
            <ItemTemplate>
                &nbsp;<asp:Label ID="TagLabel" runat="server">
                <asp:Hyperlink ID="taglink" runat="server" Text='<%# Eval("Tag") %>' NavigateUrl='<%#Eval("Tag","recipesbytag.aspx?tag={0}") %>' />
                </asp:Label><br /><br /></ItemTemplate></asp:DataList></p></div></div><p>
        <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1" AllowSorting="True" GridLines="None">
            <Columns>
                <asp:ImageField DataImageUrlField="Picture" HeaderText="Picture">
                    <ControlStyle CssClass="thumbnails" />
                    <ItemStyle Height="30px" Width="30px" />
                </asp:ImageField>
                <asp:BoundField DataField="RecipeName" HeaderText="RecipeName" 
                    SortExpression="RecipeName" />
                <asp:BoundField DataField="Description" HeaderText="Description" 
                    SortExpression="Description" />
                <asp:BoundField DataField="MealType" HeaderText="MealType" 
                    SortExpression="MealType" />
                <asp:BoundField DataField="Preparation_Time" HeaderText="Preparation_Time" 
                    SortExpression="Preparation_Time" />
                <asp:TemplateField HeaderText="Stars">
                <ItemTemplate><img alt="Star Rating" src ="<%# getImageSource(Eval("AverageRating"))%>" /></p></ItemTemplate>
                    <ControlStyle CssClass="thumbnails" />
                </asp:TemplateField>
                <asp:HyperLinkField DataNavigateUrlFields="ID" 
                    DataNavigateUrlFormatString="details.aspx?ID={0}" Text="More Details!" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
            
            
            
            SelectCommand="SELECT [Picture], [RecipeName], [Description], [MealType], [Preparation_Time], [AverageRating], [ID] FROM [FullQueryRating]">
        </asp:SqlDataSource>
    <br />
</p>
<p>
</p>
</asp:Content>
